package test;

import java.io.IOException;
import java.util.HashMap;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import aorey.config.FrameworkConfig;
import aorey.web.WebTemplate;

/**
 * Servlet implementation class p
 */
@WebServlet("/p")
public class p extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public p() {
        super();
        
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		WebTemplate template = new WebTemplate(request.getRealPath("")+FrameworkConfig.templateConfig);	
		HashMap<String, Object> data = new HashMap<>();
		data.put("key1", "aaaaaaaaaaaaaaaaaa");
		data.put("key2","cccccccccccccccccccc");
		template.bind(data);
		String html = template.getTemplate("/test_tpl.html");
		response.getWriter().append(html);
		response.getWriter().close();
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		doGet(request, response);
	}

}
